$(function(){

	/*advert*/
	(function(){
		var advert_main1 = $('#advert .advert_main .advert_main_content1');
		var advert_main2 = $('#advert .advert_main .advert_main_content2');
		var advert_a1 = $('#advert .advert_main>a:nth-child(1)');
		var advert_a2 = $('#advert .advert_main>a:nth-child(3)');
		advert_a1.hover(function(){
			advert_main1.css('display','block');
			advert_main2.css('display','none');
		});
		advert_a2.hover(function(){
			advert_main1.css('display','none');
			advert_main2.css('display','block');
		});
	})();
	/*轮播图*/
	bannerAuto( $(".banner1 .tab1 a") , $(".banner1 .btn1 a") , $(".banner1 .slide-wrap1 ul") , $(".banner1") , "click" ,$(".banner1 .slide-wrap1") , 3000 );
	bannerAuto( $(".banner2 .tab2 a") , $(".banner2 .btn2 a") , $(".banner2 .slide-wrap2 ul") , $(".banner2") , "click" ,$(".banner2 .slide-wrap2") , 4000 );
	bannerAuto( $(".banner3 .tab3 a") , $(".banner3 .btn3 a") , $(".banner3 .slide-wrap3 ul") , $(".banner3") , "click" ,$(".banner3 .slide-wrap3") , 5000 );
	bannerAuto( $(".banner4 .tab4 a") , $(".banner4 .btn4 a") , $(".banner4 .slide-wrap4 ul") , $(".banner4") , "click" ,$(".banner4 .slide-wrap4") , 2000 );
	bannerAuto( $(".banner5 .tab5 a") , $(".banner5 .btn5 a") , $(".banner5 .slide-wrap5 ul") , $(".banner5") , "click" ,$(".banner5 .slide-wrap5") , 6000 );
	bannerAuto( $(".banner6 .tab6 a") , $(".banner6 .btn6 a") , $(".banner6 .slide-wrap6 ul") , $(".banner6") , "click" ,$(".banner6 .slide-wrap6") , 4000 );
	function bannerAuto( $tabA , $btnA , $wrapUl , $box , event , $w , T ){
		var index1 = 0;
		var nowDate = new Date();
		var timer = null;
		var W = $w.width();
		
		$tabA[event](function(){
			index1 = $(this).index();
			$(this).addClass("active").siblings().removeClass("active");
			//console.log(index1)
			$wrapUl.animate({"marginLeft":-W*(index1+1)},500);
		});

		$btnA.click(function(){
			if(	new Date() - nowDate > 600 ){
				nowDate = new Date();
				var n = $(this).index();
				n?index1++:index1--;
				play();
			}
		});
		
		$box.hover(function(){//鼠标移入
			clearInterval(timer);
		},function(){//鼠标移开
			timeAuto();
		});

		
		timeAuto();
		function timeAuto(){
			timer = setInterval(function(){
				index1++;
				play();
			},T);
		};

		function play(){
			var aindex = index1;
			//console.log($tabA.length)
			if( aindex == $tabA.length){
				aindex = 0;
			}else if(aindex < 0){
				aindex = $tabA.length-1;
			}
			$tabA.eq(aindex).addClass("active").siblings().removeClass("active");
			
			$wrapUl.animate({"marginLeft":-W*(index1+1)},500,function(){
				if(index1 == $tabA.length){
					$wrapUl.css("marginLeft",-W+"px");
					index1 = 0
				}else if(index1 < 0){
					$wrapUl.css("marginLeft",-W*( $tabA.length )+"px");
					index1 = $tabA.length-1;
				}
			});
		}
	};
	
	/*要闻*/
	(function(){
		var importantNew_midLi1 = $('.importantNew_mid>ul>li:nth-child(1)');
		var importantNew_midLi2 = $('.importantNew_mid>ul>li:nth-child(2)');
		var importantNew_midLi3 = $('.importantNew_mid>ul>li:nth-child(3)');
		var importantNew_midContent = $('.importantNew_mid>ul>li .importantNew_mid_content');
		var importantNew_mid1 = $('#main #importantNew .importantNew_mid>ul>li:nth-child(1)>a');
		var importantNew_mid2 = $('#main #importantNew .importantNew_mid>ul>li:nth-child(2)>a');
		var importantNew_mid3 = $('#main #importantNew .importantNew_mid>ul>li:nth-child(3)>a');
		var place_span = $('#main #importantNew .importantNew_mid>ul>li:nth-child(2)>a>span');
		var place = $('.place');
		importantNew_midLi1.hover(function(){
			$(this).find('.importantNew_mid_content').css('display','block');
			importantNew_mid1.addClass('sr-only');
			importantNew_mid2.removeClass('sr-only');
			importantNew_mid3.removeClass('sr-only');
			importantNew_midLi2.find('.importantNew_mid_content').css('display','none');
			importantNew_midLi3.find('.importantNew_mid_content').css('display','none');
		});
		importantNew_midLi2.hover(function(){
			$(this).find('.importantNew_mid_content').css('display','block');
			importantNew_mid2.addClass('sr-only');
			importantNew_mid1.removeClass('sr-only');
			importantNew_mid3.removeClass('sr-only');
			importantNew_midLi1.find('.importantNew_mid_content').css('display','none');
			importantNew_midLi3.find('.importantNew_mid_content').css('display','none');
		});
		importantNew_midLi3.hover(function(){
			$(this).find('.importantNew_mid_content').css('display','block');
			importantNew_mid3.addClass('sr-only');
			importantNew_mid1.removeClass('sr-only');
			importantNew_mid2.removeClass('sr-only');
			importantNew_midLi1.find('.importantNew_mid_content').css('display','none');
			importantNew_midLi2.find('.importantNew_mid_content').css('display','none');
		});
		place_span.hover(function(){
			place.css('display','block');
		},function(){
			place.css('display','none');
		});
		place.hover(function(){
			place.css('display','block');
		},function(){
			place.css('display','none');
		});
	})();
	/*music*/
	(function(){
		var musicList = $('.importantNew_right_top_bottom dl dd:nth-child(3)>span:nth-child(5)');
		var musicContent = $('.music_list');
		var musicList_top = $('.music_list .music_list_top>a');
		var mid1 = 0;
		musicList.click(function(){
			mid1++;
			if(mid1%2 == 0){
				musicContent.css('display','none');
			}else{
				musicContent.css('display','block');
			}
		});
		musicList_top.click(function(){
			musicContent.css('display','none');
		});
	})();
		
	openClass_tab2( $('#importantNew .importantNew_right_bottom>ul>li:nth-child(1)'),
	$('#importantNew .importantNew_right_bottom>ul>li:nth-child(2)'),
	$('#importantNew .importantNew_right_bottom>ul>li:nth-child(1)>a'),
	$('#importantNew .importantNew_right_bottom>ul>li:nth-child(2)>a'));/*公开课*/	
	openClass_tab2( $('#car .importantNew_right_bottom>ul>li:nth-child(1)'),
	$('#car .importantNew_right_bottom>ul>li:nth-child(2)'),
	$('#car .importantNew_right_bottom>ul>li:nth-child(1)>a'),
	$('#car .importantNew_right_bottom>ul>li:nth-child(2)>a'));/*健康*/	
	openClass_tab2( $('#technology .importantNew_right_bottom>ul>li:nth-child(1)'),
	$('#technology .importantNew_right_bottom>ul>li:nth-child(2)'),
	$('#technology .importantNew_right_bottom>ul>li:nth-child(1)>a'),
	$('#technology .importantNew_right_bottom>ul>li:nth-child(2)>a'));/*贵金属*/	
	openClass_tab2( $('#tourism .importantNew_right_bottom>ul>li:nth-child(1)'),
	$('#tourism .importantNew_right_bottom>ul>li:nth-child(2)'),
	$('#tourism .importantNew_right_bottom>ul>li:nth-child(1)>a'),
	$('#tourism .importantNew_right_bottom>ul>li:nth-child(2)>a'));/*易商城*/	
	openClass_tab2( $('#music .music_right_mid .importantNew_right_bottom>ul>li:nth-child(1)'),
	$('#music .music_right_mid .importantNew_right_bottom>ul>li:nth-child(2)'),
	$('#music .music_right_mid .importantNew_right_bottom>ul>li:nth-child(1)>a'),
	$('#music .music_right_mid .importantNew_right_bottom>ul>li:nth-child(2)>a'));/*网易美女直播*/	
	openClass_tab2( $('#music .music_right_bottom .importantNew_right_bottom>ul>li:nth-child(1)'),
	$('#music .music_right_bottom .importantNew_right_bottom>ul>li:nth-child(2)'),
	$('#music .music_right_bottom .importantNew_right_bottom>ul>li:nth-child(1)>a'),
	$('#music .music_right_bottom .importantNew_right_bottom>ul>li:nth-child(2)>a'));/*网易商城*/	
	

	function openClass_tab2( $tabLi1 , $tabLi2 , $tabA1 , $tabA2){
		$tabLi1.hover(function(){
			$(this).find('.importantNew_right_bottom_content').css('display','block');
			$tabA1.addClass('sr-only');
			$tabA1.removeClass('sr-remove');
			$tabA2.addClass('sr-remove');
			$tabA2.removeClass('sr-only');
			$tabLi2.find('.importantNew_right_bottom_content').css('display','none');
		});
		$tabLi2.hover(function(){
			$(this).find('.importantNew_right_bottom_content').css('display','block');
			$tabA2.addClass('sr-only');
			$tabA2.removeClass('sr-remove');
			$tabA1.addClass('sr-remove');
			$tabA1.removeClass('sr-only');
			$tabLi1.find('.importantNew_right_bottom_content').css('display','none');
		});
	};
	
	hoverTab3( $("#main #sport .new_left_main>ul:nth-child(1)>li") ,
	$("#main #sport .new_left_main>ul:nth-child(1)>li .new_left_content"));/*体育*/
	hoverTab3( $("#main #money .new_left_main>ul:nth-child(1)>li") ,
	$("#main #money .new_left_main>ul:nth-child(1)>li .new_left_content"));/*财经*/
	hoverTab3( $("#main #technology .new_left_main>ul:nth-child(1)>li") ,
	$("#main #technology .new_left_main>ul:nth-child(1)>li .new_left_content"));/*科技*/
	hoverTab3( $("#main #fashion .new_left_main>ul:nth-child(1)>li") ,
	$("#main #fashion .new_left_main>ul:nth-child(1)>li .new_left_content"));/*时尚*/
	hoverTab3( $("#main #car .new_left_main>ul:nth-child(1)>li") ,
	$("#main #car .new_left_main>ul:nth-child(1)>li .new_left_content"));/*汽车*/
	function hoverTab3( goods_list ,  goods_Main){
		goods_list.hover(function(){
			$(this).addClass('sr-only').siblings().removeClass('sr-only');
			var div = {};
			div = goods_Main;
			for(var i=0;i<3;i++){
				if(i==$(this).index()){/*当循环i=0的时候*/
					div.eq(i).show();
				}else{
					div.eq(i).hide();
				}
			}
		});
	};
	
	hoverTab2( $("#main #entertainment .new_left_main>ul:nth-child(1)>li") ,
	$("#main #entertainment .new_left_main>ul:nth-child(1)>li .new_left_content"));/*娱乐*/
	hoverTab2( $("#main #house .new_left_main>ul:nth-child(1)>li") ,
	$("#main #house .new_left_main>ul:nth-child(1)>li .new_left_content"));/*房产*/
	hoverTab2( $("#main #fixture .new_left_main>ul:nth-child(1)>li") ,
	$("#main #fixture .new_left_main>ul:nth-child(1)>li .new_left_content"));/*家居*/
	function hoverTab2( goods_list ,  goods_Main){
		goods_list.hover(function(){
			$(this).addClass('sr-only').siblings().removeClass('sr-only');
			var div = {};
			div = goods_Main;
			for(var i=0;i<2;i++){
				if(i==$(this).index()){/*当循环i=0的时候*/
					div.eq(i).show();
				}else{
					div.eq(i).hide();
				}
			}
		});
	};
	
	/*网易云音乐*/
	(function(){
		var musicLi1 = $('#main #music .music_left .music_left_top>ul>li:nth-child(1)>a');
		var musicLi2 = $('#main #music .music_left .music_left_top>ul>li:nth-child(2)>a');
		var musicLi3 = $('#main #music .music_left .music_left_top>ul>li:nth-child(3)>a');
		var musicLi4 = $('#main #music .music_left .music_left_top>ul>li:nth-child(4)>a');
		var musicLi5 = $('#main #music .music_left .music_left_top>ul>li:nth-child(5)>a');
		musicLi1.hover(function(){
			$(this).addClass('music');
			$(this).css('color','#FF3333');
			musicLi2.removeClass('music');
			musicLi2.css('color','#888888');
			musicLi3.removeClass('music');
			musicLi3.css('color','#888888');
			musicLi4.removeClass('music');
			musicLi4.css('color','#888888');
			musicLi5.removeClass('music');
			musicLi5.css('color','#888888');
		});
		musicLi2.hover(function(){
			$(this).addClass('music');
			$(this).css('color','#FF3333');
			musicLi1.removeClass('music');
			musicLi1.css('color','#888888');
			musicLi3.removeClass('music');
			musicLi3.css('color','#888888');
			musicLi4.removeClass('music');
			musicLi4.css('color','#888888');
			musicLi5.removeClass('music');
			musicLi5.css('color','#888888');
		});
		musicLi3.hover(function(){
			$(this).addClass('music');
			$(this).css('color','#FF3333');
			musicLi1.removeClass('music');
			musicLi1.css('color','#888888');
			musicLi2.removeClass('music');
			musicLi2.css('color','#888888');
			musicLi4.removeClass('music');
			musicLi4.css('color','#888888');
			musicLi5.removeClass('music');
			musicLi5.css('color','#888888');
		});
		musicLi4.hover(function(){
			$(this).addClass('music');
			$(this).css('color','#FF3333');
			musicLi1.removeClass('music');
			musicLi1.css('color','#888888');
			musicLi2.removeClass('music');
			musicLi2.css('color','#888888');
			musicLi3.removeClass('music');
			musicLi3.css('color','#888888');
			musicLi5.removeClass('music');
			musicLi5.css('color','#888888');
		});
		musicLi5.hover(function(){
			$(this).addClass('music');
			$(this).css('color','#FF3333');
			musicLi1.removeClass('music');
			musicLi1.css('color','#888888');
			musicLi2.removeClass('music');
			musicLi2.css('color','#888888');
			musicLi3.removeClass('music');
			musicLi3.css('color','#888888');
			musicLi4.removeClass('music');
			musicLi4.css('color','#888888');
		});
	})();
});
